#!/bin/bash
set -e


TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage2}
SRC=${SRC:-/sources}

name=perl
version=5.32.1

rm -fr $TMP
mkdir -p $TMP $LOG

tar xf $SRC/$name-$version.tar.xz -C $TMP

{ time \
   {

    cd $TMP/$name-$version

    sh Configure -des                                       \
                -Dprefix=/usr                               \
                -Dvendorprefix=/usr                         \
                -Dprivlib=/usr/lib/perl5/5.32/core_perl     \
                -Darchlib=/usr/lib/perl5/5.32/core_perl     \
                -Dsitelib=/usr/lib/perl5/5.32/site_perl     \
                -Dsitearch=/usr/lib/perl5/5.32/site_perl    \
                -Dvendorlib=/usr/lib/perl5/5.32/vendor_perl \
                -Dvendorarch=/usr/lib/perl5/5.32/vendor_perl

    make
    
    make install

    }
} 2>&1 | tee $name.log

[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
